package com.ohs.ohsoa.system.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ohs.ohsoa.system.dto.PushlogDto;
import com.ohs.ohsoa.system.entity.Pushlog;
import com.ohs.ohsoa.system.mapper.PushlogMapper;
import com.ohs.ohsoa.system.vo.PushlogVo;
import com.ohs.ohsoa.utils.bean.requestBean.PageParam;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 我的信息
 * @author qhuang
 * @since 2021-11-8
 */
@Service
public class PushlogServiceImpl extends ServiceImpl<PushlogMapper, Pushlog> implements PushlogService{

    @Resource
    private PushlogMapper pushlogMapper;

    @Override
    public List<PushlogVo> pushlogSelectList(PageParam<PushlogDto> pageParam) {
        //获取对象
        PushlogDto pushlogDto = pageParam.getSearchbean();
        //分页
        PageHelper.startPage(pageParam.getIndexPage(), pageParam.getPageSize());
        return pushlogMapper.pushlogSelectList(pushlogDto);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean pushlogUpdateReadflg(PushlogDto pushlogDto) {
        List<String> pguids = pushlogDto.getPguids();
        for (String pguid : pguids) {
            pushlogMapper.pushlogUpdateReadflg(pguid);
        }

        return true;
    }

    @Override
    public Integer pushlogselectnotreadcount(PushlogDto pushlogDto) {
        return pushlogMapper.pushlogselectnotreadcount(pushlogDto.getPersonnelGuid());
    }
}
